package com.kanjian.music.database;

import android.database.sqlite.SQLiteDatabase;

import java.util.Map;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.DaoConfig;
import de.greenrobot.dao.AbstractDaoSession;
import de.greenrobot.dao.IdentityScopeType;

import com.kanjian.music.entity.RequestCache;
import com.kanjian.music.entity.User;
import com.kanjian.music.entity.Music;
import com.kanjian.music.entity.DownloadList;

import com.kanjian.music.database.RequestCacheDao;
import com.kanjian.music.database.UserDao;
import com.kanjian.music.database.MusicDao;
import com.kanjian.music.database.DownloadListDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * {@inheritDoc}
 *
 * @see de.greenrobot.dao.AbstractDaoSession
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig requestCacheDaoConfig;
    private final DaoConfig userDaoConfig;
    private final DaoConfig musicDaoConfig;
    private final DaoConfig downloadListDaoConfig;

    private final RequestCacheDao requestCacheDao;
    private final UserDao userDao;
    private final MusicDao musicDao;
    private final DownloadListDao downloadListDao;

    public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        requestCacheDaoConfig = daoConfigMap.get(RequestCacheDao.class).clone();
        requestCacheDaoConfig.initIdentityScope(type);
        userDaoConfig = daoConfigMap.get(UserDao.class).clone();
        userDaoConfig.initIdentityScope(type);
        musicDaoConfig = daoConfigMap.get(MusicDao.class).clone();
        musicDaoConfig.initIdentityScope(type);
        downloadListDaoConfig = daoConfigMap.get(DownloadListDao.class).clone();
        downloadListDaoConfig.initIdentityScope(type);
        requestCacheDao = new RequestCacheDao(requestCacheDaoConfig, this);
        userDao = new UserDao(userDaoConfig, this);
        musicDao = new MusicDao(musicDaoConfig, this);
        downloadListDao = new DownloadListDao(downloadListDaoConfig, this);

        registerDao(RequestCache.class, requestCacheDao);
        registerDao(User.class, userDao);
        registerDao(Music.class, musicDao);
        registerDao(DownloadList.class, downloadListDao);
    }

    public void clear() {
        requestCacheDaoConfig.getIdentityScope().clear();
        userDaoConfig.getIdentityScope().clear();
        musicDaoConfig.getIdentityScope().clear();
        downloadListDaoConfig.getIdentityScope().clear();
    }

    public void deleteAllData() {
        requestCacheDao.deleteAll();
        userDao.deleteAll();
        musicDao.deleteAll();
        downloadListDao.deleteAll();
    }


    public RequestCacheDao getRequestCacheDao() {
        return requestCacheDao;
    }
    public UserDao getUserDao() {
        return userDao;
    }
    public MusicDao getMusicDao() {
        return musicDao;
    }
    public DownloadListDao getDownloadListDao() {
        return downloadListDao;
    }
}
